package com.jackson.engineeringtechnologyguide.context;

/*
 * Author: JacksonCoder
 * FileName: ApplicationContextUtilsB
 * Version: 1.0.0
 * Date: 2025/1/10
 */

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import java.util.Objects;

@Component
public class ApplicationContextUtilsB implements ApplicationListener<ContextRefreshedEvent> {

    private static ApplicationContext context;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        if (Objects.isNull(context)) {
            // TODO
            context = event.getApplicationContext();
        }
    }

    //
    public static ApplicationContext getContext() {
        return context;
    }
}
